package cn.com.nes.site.entity.em.crm.log;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 日志操作类别 枚举类
 */
public enum LogOperateTypeEnum {

    CLUE("01","线索"),
    CUSTOMER("02","客户"),
    OPPORTUNITY("03","商机"),
    PROJECT("04", "项目"),

    ;

    private String key;

    private String value;

    LogOperateTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static LogOperateTypeEnum getEnum(String key) {
        Map<String, LogOperateTypeEnum> map = new HashMap<>();
        for (LogOperateTypeEnum logOperateTypeEnum : values()) {
            map.put(logOperateTypeEnum.getKey(), logOperateTypeEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的客户性质");
        }
        return map.get(String.valueOf(key));
    }

}
